/*
 * Copyright (c) 2011, Michael van der Westhuizen
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    - Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    - Redistributions in binary form must reproduce the above
 *      copyright notice, this list of conditions and the following
 *      disclaimer in the documentation and/or other materials provided
 *      with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef PYXMLSEC1_LIST_C_MCVDW_20110104
#define PYXMLSEC1_LIST_C_MCVDW_20110104

#include "pyxmlsec.h"

#include <xmlsec/list.h>


/* PyDoc_STRVAR(xmlsec1_xmlSecList_doc, "base64 objects."); */

static PyObject * xmlsec1_xmlSecPtrListCreate(PyObject * self, PyObject * arg)
{
    xmlSecPtrListPtr list;

    if (NULL == (list = xmlSecPtrListCreate(xmlsec1mod_unwrap_xmlSecPtrListId(arg))))
    {
        ENSURE_EXCEPTION_SET(xmlSecPtrListCreate);
        return NULL;
    }

    return xmlsec1mod_wrap_xmlSecPtrListPtr(list);
}



static PyObject * xmlsec1_xmlSecPtrListDestroy(PyObject * self, PyObject * arg)
{
    xmlSecPtrListPtr list;

    if (NULL == (list = xmlsec1mod_unwrap_xmlSecPtrListPtr(arg)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecPtrListPtr);
        return NULL;
    }

    xmlSecPtrListDestroy(list);
    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecPtrListInitialize(PyObject * self, PyObject * args, PyObject * kwds)
{
    xmlSecPtrListPtr list;
    xmlSecPtrListId id;
    PyObject * list_;
    PyObject * id_;

    static char * kwlist[] = {"list", "id", NULL};

    list = NULL;
    id = NULL;
    list_ = NULL;
    id_ = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &list_, &id_))
    {
        return NULL;
    }

    if (NULL == (list = xmlsec1mod_unwrap_xmlSecPtrListPtr(list_)))
    {
        return NULL;
    }

    if (NULL == (id = xmlsec1mod_unwrap_xmlSecPtrListId(id_)))
    {
        return NULL;
    }

    xmlSecPtrListFinalize(list);

    if (0 != xmlSecPtrListInitialize(list, id))
    {
        ENSURE_EXCEPTION_SET(xmlSecPtrListInitialize);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecStringListGetKlass(PyObject * self, PyObject * args)
{
    return xmlsec1mod_wrap_xmlSecPtrListId(xmlSecStringListGetKlass());
}

#endif
